package com.mycompany.project.client;


import java.util.LinkedList;

import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VLayout;

public class AnnotationPreviewPanel extends Canvas {

	VerticalPanel verticalPreviewContainer;
	LinkedList<VideoAnnotationPreview> previews;
	
	public AnnotationPreviewPanel(int xPos,int yPos, int width, int height){

		//Canvas annotationPrewPanel = new Canvas();
		previews=new LinkedList<VideoAnnotationPreview>();
		setStyleName("AnnotationPreviewPanel");							
		setSize(width +"px", height +"px");
		setPageLeft(xPos);					
		setPageTop(yPos);
		VLayout previewContainer = new VLayout();
		previewContainer.setSize("100%", "100%");
		ScrollPanel scrollPanelPreview = new ScrollPanel();
		previewContainer.addMember(scrollPanelPreview);
		scrollPanelPreview.setSize("100%", getHeightAsString() + "px");		
		verticalPreviewContainer = new VerticalPanel();
		scrollPanelPreview.setWidget(verticalPreviewContainer);
		verticalPreviewContainer.setSize("100%", "100%");
		addChild(previewContainer);
		previewContainer.moveTo(0, 0);
	}
	
	
	public int addPreview(VideoAnnotationPreview videoAnnPrew){
		verticalPreviewContainer.add(videoAnnPrew); 
		previews.add(videoAnnPrew);		
		return(previews.size()-1);
	}
	
	private void setPreviewText(int index,String descriptionText){
		previews.get(index).setDescriptionPreview(descriptionText);
	}
	
	public void updatePreviewTextDescription(String updateText,int previewIndex){
		setPreviewText(previewIndex, updateText);
	}
	
	public void updateAnnotationPreviewTimeSegment(int previewIndex, double timeStart, double timeEnd){
		previews.get(previewIndex).setPreviewTimeSegment(timeStart, timeEnd);
	}
	
}
